﻿/*
///    This file is part of BannerLib4Net.
///
///    BannerLib4Net is free software: you can redistribute it and/or modify
///    it under the terms of the GNU General Public License as published by
///    the Free Software Foundation, either version 3 of the License, or
///    (at your option) any later version.

///    BannerLib4Net is distributed in the hope that it will be useful,
///    but WITHOUT ANY WARRANTY; without even the implied warranty of
///    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
///    GNU General Public License for more details.
///
///    You should have received a copy of the GNU General Public License
///    along with BannerLib4Net.  If not, see <http://www.gnu.org/licenses/>.
*/


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BannerLib4Net.Data.Validation
{
    public class DataInputValidator
    {
        public static object CheckInputInt16Value(Int16 evalInt)
        {
            object retval = DBNull.Value;

            if (evalInt != Int16.MinValue)
            {
                retval = evalInt;
            }

            return retval;
        }

        public static object CheckInputInt32Value(Int32 evalInt)
        {
            object retval = DBNull.Value;

            if (evalInt != Int32.MinValue)
            {
                retval = evalInt;
            }

            return retval;
        }

        public static object CheckInputInt32Value(Int32? evalInt)
        {
            object retval = DBNull.Value;

            if (evalInt.HasValue)
            {
                retval = evalInt.Value;
            }

            return retval;
        }

        public static object CheckInputInt64Value(Int64 evalInt)
        {
            object retval = DBNull.Value;

            if (evalInt != Int64.MinValue)
            {
                retval = evalInt;
            }

            return retval;
        }

        public static object CheckInputInt64Value(Int64? evalInt)
        {
            object retval = DBNull.Value;

            if (evalInt.HasValue)
            {
                retval = evalInt.Value;
            }

            return retval;
        }


        public static object CheckInputStringValue(String evalString)
        {
            object retval = DBNull.Value;

            if (!String.IsNullOrEmpty(evalString))
            {
                retval = evalString;
            }

            return retval;
        }

        public static object CheckInputDateTimeValue(DateTime evalDate)
        {
            object retval = DBNull.Value;

            if (evalDate != DateTime.MinValue)
            {
                retval = evalDate;
            }

            return retval;
        }

        public static object CheckInputDecimalValue(Decimal evalDecimal)
        {
            object retval = DBNull.Value;

            if (evalDecimal != Decimal.MinValue)
            {
                retval = evalDecimal;
            }

            return retval;
        }

        public static object CheckInputDoubleValue(Double evalDouble)
        {
            object retval = DBNull.Value;

            if (evalDouble != Double.MinValue)
            {
                retval = evalDouble;
            }

            return retval;
        }
    }
}
